package http

//用于暴露Host service接口
import (
	"github.com/gin-gonic/gin"
	"github.com/infraboard/mcube/http/response"

	"gitee.com/king_max/restful-api-demo/apps/host"
)

//gin.Default()
func (h *Handler) createHost(c *gin.Context){
	ins := host.NewHost()
	if err := c.Bind(ins);err !=nil{
		//code int, contentType string, data []byte)
		// c.Data(http.StatusBadRequest,"application/json",[]byte(ins.Name))
		// response.Data()
		response.Failed(c.Writer,err)
		return
	}
	//进行接口调用
	// h.svc.CreateHost(nil,nil)
	// c.JSON(200,gin.H{
	// 	"message":"test success",
	// })

	//进行接口调用
	ins,err := h.svc.CreateHost(c.Request.Context(),ins)
	if err != nil{
		response.Failed(c.Writer,err)
	}
	response.Success(c.Writer,ins)
}

